/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jifAdministrarProveedor.java
 *
 * Created on 15/07/2010, 11:39:20 
 */

package Proveedores;

import administracion.delegate.GestionPedidosDelegate;
import administracion.helper.Listas;
import administracion.helper.Utiles_MensajesDialogo;
import administracion.helper.Utiles_Validar;
import com.jidesoft.hints.ListDataIntelliHints;
import java.awt.event.KeyEvent;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.text.MaskFormatter;
import suministros.ejb30.TO.DepartamentoTO;
import suministros.ejb30.TO.DistritoTO;
import suministros.ejb30.TO.PaisTO;
import suministros.ejb30.TO.ProveedorTO;
import suministros.ejb30.TO.ProvinciaTO;
import suministros.ejb30.TO.TipoTO;
import suministros.ejb30.entity.Departamento;
import suministros.ejb30.entity.Direccionnopersona;
import suministros.ejb30.entity.Distrito;
import suministros.ejb30.entity.Pais;
import suministros.ejb30.entity.Proveedor;
import suministros.ejb30.entity.Provincia;
import suministros.ejb30.entity.Tipo;
import suministros.ejb30.helper.Utiles_Convertir;

/**
 *
 * @author Arturo
 */
public class jifAdministrarProveedor extends javax.swing.JInternalFrame {
        private ListDataIntelliHints intelliHintsProveedor;
         List listaDepartamento=new ArrayList();
         List listaProvincia=new ArrayList();
         List listaDistrito=new ArrayList();
         List listaPaises=new ArrayList();
         List listaTipos=new ArrayList();
         List listaTipos2=new ArrayList();
         ProveedorTO proveed;
         List<Proveedor> proveedores;
         private MaskFormatter mascaraRuc;
        private MaskFormatter mascaraDni;
        private MaskFormatter RPNServicios;
        private MaskFormatter RPNBienes;
        private MaskFormatter mascaraNumero;

    /** Creates new form jifAdministrarProveedor */
    public jifAdministrarProveedor() {
         construirMascaras();
        initComponents();   
        try {
            cargaHintsIndependientes();
        } catch (Exception ex) {
            Logger.getLogger(jifAdministrarProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
        llenarComboDepartamento();
        this.llenarComboResidencia();
        this.llenarComboVia();
        this.llenarComboPaises();
    }
     private void construirMascaras() {
        try {
          this.mascaraRuc = new MaskFormatter("###########");
          this.mascaraDni = new MaskFormatter("########");
          this.RPNBienes = new MaskFormatter("##########");
          this.RPNServicios = new MaskFormatter("##########");
          this.mascaraNumero= new MaskFormatter("#0");

        } catch (ParseException ex) {
          Logger.getLogger(jifIngresarProveedor.class.getName()).log(Level.SEVERE, null, ex);
          ex.printStackTrace();
        }
     }
     private void llenarComboDepartamento() {
        listaDepartamento = null;
        List listaDepartamento_cbo = this.cboBeanBindingDepartamento1.getLista();
        listaDepartamento_cbo.clear();
        try
        {
          listaDepartamento = Listas.getDepartamentos();
          this.cboBeanBindingDepartamento1.setLista(listaDepartamento);
          this.bindingGroup.bind();
          this.jcboDepartamento.updateUI();
          this.jcboDepartamento.setSelectedIndex(-1);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener deparamentos\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifAdministrarProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
        }
     private void llenarComboProvincia() {
         if(this.jcboDepartamento.getSelectedIndex()>=0){
           listaProvincia = null;
        List listaProvincia_cbo = this.cboBeanBindingProvincia1.getLista();
        listaProvincia_cbo.clear();
        try
        {
          Departamento depa = Utiles_Convertir.convertirToDepartamento_DepartamentoTO((DepartamentoTO)this.jcboDepartamento.getSelectedItem());
          listaProvincia = GestionPedidosDelegate.getInstance().listaProvincias(depa.getCoddepto());
              if(!listaProvincia.isEmpty()){
                  this.cboBeanBindingProvincia1.setLista(listaProvincia);
                  this.bindingGroup.bind();
                  this.jcboProvincia.updateUI();
                  this.jcboProvincia.setSelectedIndex(0);
              }
              else{
                  this.jcboProvincia.removeAllItems();
              }

            } catch (Exception ex) {
              Utiles_MensajesDialogo.mensajeAlerta("Error al obtener provincias\n" + ex.getMessage());
              ex.printStackTrace();
              Logger.getLogger(jifIngresarProveedor.class.getName()).log(Level.SEVERE, null, ex);
            }

         }
     }
    private void llenarComboDistrito() {
        if(this.jcboProvincia.getSelectedIndex()>=0){
             listaDistrito = null;
        List listaDistrito_cbo = this.cboBeanBindingDistrito1.getLista();
        listaDistrito_cbo.clear();
        try
        {
              Provincia pro = Utiles_Convertir.convertirToPronvincia_ProvinciaTO((ProvinciaTO)this.jcboProvincia.getSelectedItem());
              listaDistrito = GestionPedidosDelegate.getInstance().listaDistritos(pro.getCodprovincia());
              if(!listaDistrito.isEmpty()) {
                  this.cboBeanBindingDistrito1.setLista(listaDistrito);
                  this.bindingGroup.bind();
                  this.jcboDistrito.updateUI();
                  this.jcboDistrito.setSelectedIndex(0);
              }
              else{
                  this.jcboDistrito.removeAllItems();
              }
            } catch (Exception ex) {
              Utiles_MensajesDialogo.mensajeAlerta("Error al obtener distrito\n" + ex.getMessage());
              ex.printStackTrace();
              Logger.getLogger(jifIngresarProveedor.class.getName()).log(Level.SEVERE, null, ex);
         }
        }
       
    }
    private void llenarComboResidencia() {
        listaTipos = null;
        List listaTipos_cbo = this.cboBeanBindingTipo1.getLista();
        listaTipos_cbo.clear();
        try
        {
          listaTipos = Listas.getTipo_porTabla("tipo_lugar_residencia");

          this.cboBeanBindingTipo1.setLista(listaTipos);
          this.bindingGroup.bind();
          this.jcboLugarResidencia.updateUI();
          this.jcboLugarResidencia.setSelectedIndex(-1);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Residencia\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifIngresarProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
      private void llenarComboPaises() {
        listaPaises = null;
        List listaPaises_cbo = this.cboBeanBindingPais1.getLista();
        listaPaises_cbo.clear();
        try
        {
          listaPaises = Listas.getPaises();
          this.cboBeanBindingPais1.setLista(listaPaises);
          this.bindingGroup.bind();
          this.jcboPais.updateUI();
          this.jcboPais.setSelectedIndex(-1);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener paises\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifIngresarProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
       private void llenarComboVia() {
        listaTipos2 = null;
        List listaTipos_cbo2 = this.cboBeanBindingTipo2.getLista();
        listaTipos_cbo2.clear();
        try
        {
          listaTipos2 = Listas.getTipo_porTabla("tipo_via");

          this.cboBeanBindingTipo2.setLista(listaTipos2);
          this.bindingGroup.bind();
          this.jcboTipoVia.updateUI();
          this.jcboTipoVia.setSelectedIndex(-1);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Vias\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifIngresarProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    public DepartamentoTO obtenerDepartamento(String nombre){
        DepartamentoTO dep= new DepartamentoTO();
        for(int i=0 ; i<listaDepartamento.size(); i++){
               try{
                if(((DepartamentoTO)listaDepartamento.get(i)).getNomDepartamento().compareTo(nombre)==0){
                   dep= (DepartamentoTO)listaDepartamento.get(i);
                 }
               }
               catch(Exception e){ }
        }
        return dep;
    }
    public ProvinciaTO obtenerProvincia(String nombre){
        ProvinciaTO pro= new ProvinciaTO();
        for(int i=0 ; i<this.listaProvincia.size(); i++){
            try{
               if(((ProvinciaTO)listaProvincia.get(i)).getNomProvincia().compareTo(nombre)==0){
                pro= (ProvinciaTO)listaProvincia.get(i);
                }
            }catch(Exception e){ }
        }
        return pro;
    }
     public DistritoTO obtenerDistrito(String nombre){
         DistritoTO dis= new DistritoTO();
        for(int i=0 ; i<this.listaDistrito.size(); i++){
            try{
                if(((DistritoTO)listaDistrito.get(i)).getNomDistrito().compareTo(nombre)==0){
                dis= (DistritoTO)listaDistrito.get(i);
             }
            }
            catch(Exception e){
            }
            
        }
        return dis;
    }

     public TipoTO obtenerResidencia(int nombre){
        TipoTO dep= new TipoTO();
        for(int i=0 ; i<listaTipos.size(); i++){
            try{
              if(((TipoTO)listaTipos.get(i)).getId_tabla_tipo().compareTo(nombre)==0){
                dep= (TipoTO)listaTipos.get(i);
            }
            }
            catch(Exception e){
            }
            
        }
        return dep;
    }
     public TipoTO obtenerVia(int nombre){
        TipoTO dep= new TipoTO();
        for(int i=0 ; i<listaTipos2.size(); i++){
            try {
                if (((TipoTO) listaTipos2.get(i)).getId_tabla_tipo().compareTo(nombre) == 0) {
                    dep = (TipoTO) listaTipos2.get(i);
                }
            } catch (Exception e) {
            }
        }
        return dep;
    }
         public PaisTO obtenerPaises(String nombre){
        PaisTO dep= new PaisTO();
        for(int i=0 ; i<listaPaises.size(); i++){
            try {
                if (((PaisTO) listaPaises.get(i)).getCodPais().compareTo(nombre) == 0) {
                    dep = (PaisTO) listaPaises.get(i);
                }
            } catch (Exception e) {
            }
        }
        return dep;
    }
 private void buscarRazonSocial()
  {
    ProveedorTO pro;
    if (this.jftRuc.getText().trim().length() < 1) {
      try { pro = (ProveedorTO)this.intelliHintsProveedor.getSelectedHint();
      } catch (NullPointerException ex) {
        pro = null;
      }
    } else {
      pro = Listas.getProveedorcodigo(this.jftRuc.getText().trim());
    }
    if (pro == null) {
      Utiles_MensajesDialogo.mensajeError("El proveedor no existe!");
      this.jftRuc.setText("");
      pro = null;
    } else {
      this.jftfRazon.setText(pro.getRazon() + " - " + pro.getCodProveedor());
      this.jftRuc.setText(pro.getCodProveedor());
      this.llenarComboDepartamento();
      this.llenarComboPaises();
      this.llenarComboResidencia();
      this.llenarComboVia();
      this.limpiar();
      buscarProveedor();
    }
    
  }
public void buscarProveedor(){
     proveed= new ProveedorTO();
        try {
            proveed = GestionPedidosDelegate.getInstance().obtenerDatosProveedor(this.jftRuc.getText().trim());
        } catch (Exception ex) {
            Logger.getLogger(jifAdministrarProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
    if(proveed==null){
        Utiles_MensajesDialogo.mensajeError("El proveedor no existe!");
        this.jftRuc.setText("");
        this.jftfRazon.setText("");
        proveed = null;
        limpiar();
    }
    else{
        this.jftDni.setText(proveed.getDni());
        this.jftRepresentante.setText(proveed.getRepresentante());
        this.jftTelefono.setText(proveed.getTelefonos());
        this.jftFax.setText(proveed.getFax());
        this.jftCorreo.setText(proveed.getCorreo());
        this.jftGiroNegocio.setText(proveed.getGiroNegocio());
        this.jckCosechador.setSelected(proveed.getCosechador());
            if(this.obtenerPaises(proveed.getCodpais()).getCodPais().compareTo("1")==0){
            this.jrbNacional.setSelected(true);
            this.jrbExtranjero.setSelected(false);
            this.jcboPais.setSelectedIndex(0);
            this.ocultaPanel();
            this.jcboDepartamento.setSelectedItem(this.obtenerDepartamento(proveed.getCoddepartamento()));
            this.llenarComboProvincia();
            this.jcboProvincia.setSelectedItem(this.obtenerProvincia(proveed.getCodprovincia()));
            this.llenarComboDistrito();
            this.jcboDistrito.setSelectedItem(this.obtenerDistrito(proveed.getCoddistrito()));
            this.jcboPais.setSelectedItem(this.obtenerPaises(proveed.getCodpais()));
            this.jcboTipoVia.setSelectedItem(this.obtenerVia(proveed.getCodVia()));
            this.jcboLugarResidencia.setSelectedItem(this.obtenerResidencia(proveed.getCodResidencia()));
            this.jftResidencia.setText(proveed.getNomResidencia());
            this.jftVia.setText(proveed.getNomVia());
            if(proveed.getNumero() ==null){
                 this.jftNumero.setText("");
            }
            else{
                 this.jftNumero.setText(proveed.getNumero()+"");
            }
           
            this.jftReferencia.setText(proveed.getReferencia().toString());
        }
        else{
            this.jrbNacional.setSelected(false);
            this.jrbExtranjero.setSelected(true);
            this.ocultaPanel();
            this.jcboPais.setSelectedItem(this.obtenerPaises(proveed.getCodpais()));
            this.jftReferencia.setText(proveed.getReferencia());
        }

    }
 }
 private void cargaHintsIndependientes() throws Exception {
    this.intelliHintsProveedor = new ListDataIntelliHints(this.jftfRazon, Listas.getProveedores());
  }
 public void modificarProveedor() throws Exception{
         Proveedor pro= new Proveedor();
         pro.setCodProveedor(proveed.getCodProveedor());
         pro.setRazonSocial(proveed.getRazon());
         if(this.jftDni.getText().compareTo("")!=0)
         pro.setDniRepLegal(this.jftDni.getText());
         if(this.jftTelefono.getText().compareTo("")!=0)
         pro.setTelefonos(this.jftTelefono.getText());
         if(this.jftFax.getText().compareTo("")!=0)
         pro.setFax(this.jftFax.getText());
         if(this.jftCorreo.getText().compareTo("")!=0)
         pro.setCorreo(this.jftCorreo.getText());
         if(this.jftGiroNegocio.getText().compareTo("")!=0)
         pro.setGiroNegocio(this.jftGiroNegocio.getText());
         if(this.jftRepresentante.getText().compareTo("")!=0)
         pro.setRepLegal(this.jftRepresentante.getText());
         boolean cos=false;
         if(this.jckCosechador.isSelected()){
             cos=true;
         }
         pro.setIsCosechador(cos);
         Direccionnopersona dir= new Direccionnopersona();
         Pais pais = Utiles_Convertir.convertirToPais_PaisTO((PaisTO)this.jcboPais.getSelectedItem());
         if(this.jrbNacional.isSelected()){
                 Tipo via=new Tipo();
                 Tipo residencia= new Tipo();
                 Distrito dis= new Distrito() ;
                 if(this.jcboTipoVia.getSelectedIndex()>=0)
                 via = Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.jcboTipoVia.getSelectedItem());
                 if(this.jcboLugarResidencia.getSelectedIndex()>=0)
                 residencia = Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.jcboLugarResidencia.getSelectedItem());
                 if(this.jcboDistrito.getSelectedIndex()>=0)
                 dis = Utiles_Convertir.convertirToDistrito_DistritoTO((DistritoTO)this.jcboDistrito.getSelectedItem());
                if(dis== null){
                 dir.setCodpais(pais);
                }
                else{
                 dir.setCodTipoLugarResidencia(residencia);
                 dir.setCodTipoVia(via);
                 dir.setCodpais(pais);
                 dir.setCodDistritoDir(dis);
                 if(this.jftResidencia.getText().compareTo("")!=0)
                 dir.setLugarResidencia(this.jftResidencia.getText());
                   if(this.jftVia.getText().compareTo("")!=0)
                 dir.setNomVia(this.jftVia.getText());
                   if(this.jftNumero.getText().compareTo("")!=0)
                 dir.setNumero(this.jftNumero.getText());
                   if(this.jftReferencia.getText().compareTo("")!=0)
                 dir.setReferDir(this.jftReferencia.getText());
                }
         }
          else{
             dir.setCodpais(pais);
         }
        
        try {
            if(GestionPedidosDelegate.getInstance().modificarProveedor(pro, dir));
        } catch (Exception ex) {
            Logger.getLogger(jifIngresarProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
 }
 private void ocultaPanel()
      {
        boolean ocultar = this.jrbNacional.isSelected();
        String texto = null;
        this.jpNacional.setVisible(ocultar);
        if (!ocultar) {
          this.jftReferencia.setText(texto);
        }
        this.pack();
    }
   public void eliminarProveedor(){
        try {          
            if(GestionPedidosDelegate.getInstance().eliminarProvedo(this.jftRuc.getText().trim())){
            }
        } catch (Exception ex) {
            Logger.getLogger(jifAdministrarProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
   }
   public void limpiar(){
     this.jftCorreo.setText("");
     this.jftDni.setText("");
     this.jftFax.setText("");
     this.jftGiroNegocio.setText("");
     this.jftNumero.setText("");;
     this.jftReferencia.setText("");
     this.jftRepresentante.setText("");
     this.jftResidencia.setText("");
     this.jftTelefono.setText("");
     this.jftVia.setText("");
     this.jcboDepartamento.setSelectedItem(-1);
     this.jcboDistrito.setSelectedItem(-1);
     this.jcboLugarResidencia.setSelectedItem(-1);
     this.jcboPais.setSelectedItem(-1);
     this.jcboProvincia.setSelectedItem(-1);
     this.jcboTipoVia.setSelectedItem(-1);

 }
   public void verificaGuardaDatos() throws Exception {
        if(this.jftRuc.getText().compareTo("")==0){
             throw new Exception("Debe ingresar un numero de ruc");
        }
         if(this.jftfRazon.getText().compareTo("")==0){
             throw new Exception("Debe ingresar un nombre de razon social");
        }
        if(this.obtenerPaises(this.jcboPais.getSelectedItem().toString())==null){
             throw new Exception("Debe seleccionar un pais");
        }
       
        this.modificarProveedor();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        cboBeanBindingDepartamento1 = new administracion.BeanBinding.CboBeanBindingDepartamento();
        cboBeanBindingDistrito1 = new administracion.BeanBinding.CboBeanBindingDistrito();
        cboBeanBindingPais1 = new administracion.BeanBinding.CboBeanBindingPais();
        cboBeanBindingProvincia1 = new administracion.BeanBinding.CboBeanBindingProvincia();
        cboBeanBindingTipo1 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingTipo2 = new administracion.BeanBinding.CboBeanBindingTipo();
        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jrbNacional = new javax.swing.JRadioButton();
        jrbExtranjero = new javax.swing.JRadioButton();
        jftfRazon = new javax.swing.JTextField();
        jftRepresentante = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jftTelefono = new javax.swing.JTextField();
        jftFax = new javax.swing.JTextField();
        jftCorreo = new javax.swing.JTextField();
        jpNacional = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jcboTipoVia = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        jftResidencia = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jcboDistrito = new javax.swing.JComboBox();
        jLabel17 = new javax.swing.JLabel();
        jftVia = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jcboDepartamento = new javax.swing.JComboBox();
        jcboProvincia = new javax.swing.JComboBox();
        jcboLugarResidencia = new javax.swing.JComboBox();
        jftNumero = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jcboPais = new javax.swing.JComboBox();
        jLabel21 = new javax.swing.JLabel();
        jftGiroNegocio = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jftReferencia = new javax.swing.JTextField();
        jbModificar = new javax.swing.JButton();
        jbCancelar = new javax.swing.JButton();
        jbtBuscar = new javax.swing.JButton();
        jbEliminar = new javax.swing.JButton();
        jftDni = new javax.swing.JFormattedTextField(this.mascaraDni);
        jftRuc = new javax.swing.JFormattedTextField(this.mascaraRuc);
        jckCosechador = new javax.swing.JCheckBox();

        setIconifiable(true);
        setTitle("ADMINISTRAR PROVEEDORES");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/logo.png"))); // NOI18N

        jLabel1.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel1.setText("RUC de Proveedor:");

        jLabel2.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel2.setText("Razon Social:");

        jLabel3.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel3.setText("Representante Legal:");

        jLabel4.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel4.setText("DNI Representante:");

        jLabel5.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel5.setText("Procedencia: ");

        buttonGroup1.add(jrbNacional);
        jrbNacional.setFont(new java.awt.Font("Arial", 1, 12));
        jrbNacional.setText("Nacional");
        jrbNacional.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jrbNacionalActionPerformed(evt);
            }
        });

        buttonGroup1.add(jrbExtranjero);
        jrbExtranjero.setFont(new java.awt.Font("Arial", 1, 12));
        jrbExtranjero.setText("Extranjera");
        jrbExtranjero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jrbExtranjeroActionPerformed(evt);
            }
        });

        jftfRazon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jftfRazonActionPerformed(evt);
            }
        });
        jftfRazon.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jftfRazonKeyPressed(evt);
            }
        });

        jftRepresentante.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jftRepresentanteKeyPressed(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel11.setText("Telefono:");

        jLabel12.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel12.setText("Fax:");

        jLabel13.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel13.setText("Correo:");

        jftTelefono.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jftTelefonoKeyPressed(evt);
            }
        });

        jftFax.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jftFaxKeyPressed(evt);
            }
        });

        jftCorreo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jftCorreoKeyPressed(evt);
            }
        });

        jpNacional.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel6.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel6.setText("Departamento");
        jpNacional.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1));

        jLabel7.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel7.setText("Provincia");
        jpNacional.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 10, -1, -1));

        jLabel8.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel8.setText("Distrito");
        jpNacional.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 10, -1, -1));

        jLabel14.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel14.setText("Tipo Via:");
        jpNacional.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, -1, -1));

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingTipo2, eLProperty, jcboTipoVia);
        bindingGroup.addBinding(jComboBoxBinding);

        jpNacional.add(jcboTipoVia, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 70, 170, -1));

        jLabel15.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel15.setText("Nombre Via:");
        jpNacional.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 70, -1, -1));
        jpNacional.add(jftResidencia, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 40, 260, -1));

        jLabel16.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel16.setText("Tipo Lugar Residencia:");
        jpNacional.add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, -1, -1));

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingDistrito1, eLProperty, jcboDistrito);
        bindingGroup.addBinding(jComboBoxBinding);

        jcboDistrito.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcboDistritoItemStateChanged(evt);
            }
        });
        jpNacional.add(jcboDistrito, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 10, 110, -1));

        jLabel17.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel17.setText("Lugar Residencia:");
        jpNacional.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 40, -1, -1));
        jpNacional.add(jftVia, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 70, 160, -1));

        jLabel18.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel18.setText("Numero:");
        jpNacional.add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 70, 50, -1));

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingDepartamento1, eLProperty, jcboDepartamento);
        bindingGroup.addBinding(jComboBoxBinding);

        jcboDepartamento.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcboDepartamentoItemStateChanged(evt);
            }
        });
        jcboDepartamento.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jcboDepartamentoKeyReleased(evt);
            }
        });
        jpNacional.add(jcboDepartamento, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 10, 170, -1));

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingProvincia1, eLProperty, jcboProvincia);
        bindingGroup.addBinding(jComboBoxBinding);

        jcboProvincia.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcboProvinciaItemStateChanged(evt);
            }
        });
        jpNacional.add(jcboProvincia, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 10, 130, -1));

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingTipo1, eLProperty, jcboLugarResidencia);
        bindingGroup.addBinding(jComboBoxBinding);

        jpNacional.add(jcboLugarResidencia, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 40, 170, -1));
        jpNacional.add(jftNumero, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 70, 40, -1));

        jLabel20.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel20.setText("Pais:");

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingPais1, eLProperty, jcboPais);
        bindingGroup.addBinding(jComboBoxBinding);

        jLabel21.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel21.setText("Giro del Negocio:");

        jLabel19.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel19.setText("Referencia:");

        jbModificar.setFont(new java.awt.Font("Arial", 1, 12));
        jbModificar.setText("Modificar");
        jbModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbModificarActionPerformed(evt);
            }
        });

        jbCancelar.setFont(new java.awt.Font("Arial", 1, 12));
        jbCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jbCancelar.setText("Cerrar");
        jbCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCancelarActionPerformed(evt);
            }
        });

        jbtBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/find.png"))); // NOI18N
        jbtBuscar.setText("Buscar");
        jbtBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtBuscarActionPerformed(evt);
            }
        });

        jbEliminar.setFont(new java.awt.Font("Tahoma", 1, 12));
        jbEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/edit_delete.png"))); // NOI18N
        jbEliminar.setText("Dar de Baja");
        jbEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbEliminarActionPerformed(evt);
            }
        });

        jftDni.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jftDniKeyPressed(evt);
            }
        });

        jftRuc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jftRucActionPerformed(evt);
            }
        });
        jftRuc.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jftRucKeyPressed(evt);
            }
        });

        jckCosechador.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jckCosechador.setText("COSECHADOR");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jftDni, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
                            .addComponent(jftRuc, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3))
                        .addGap(32, 32, 32)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jftRepresentante, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE)
                            .addComponent(jftfRazon, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtBuscar)))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel21)
                        .addGap(25, 25, 25)
                        .addComponent(jftGiroNegocio, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jckCosechador))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(68, 68, 68)
                        .addComponent(jftTelefono, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
                        .addGap(10, 10, 10)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jftFax, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jftCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(42, 42, 42)
                        .addComponent(jrbNacional)
                        .addGap(25, 25, 25)
                        .addComponent(jrbExtranjero)
                        .addGap(72, 72, 72)
                        .addComponent(jLabel20)
                        .addGap(22, 22, 22)
                        .addComponent(jcboPais, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(98, 98, 98))
            .addGroup(layout.createSequentialGroup()
                .addComponent(jpNacional, javax.swing.GroupLayout.DEFAULT_SIZE, 708, Short.MAX_VALUE)
                .addGap(20, 20, 20))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel19)
                .addGap(64, 64, 64)
                .addComponent(jftReferencia, javax.swing.GroupLayout.DEFAULT_SIZE, 579, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(214, Short.MAX_VALUE)
                .addComponent(jbModificar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbEliminar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbCancelar)
                .addGap(201, 201, 201))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(21, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(jftRuc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel2))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jftfRazon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jbtBuscar)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jftDni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel3)
                    .addComponent(jftRepresentante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel11)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jftTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel12)
                        .addComponent(jftFax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel13)
                        .addComponent(jftCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel21)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jftGiroNegocio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jckCosechador)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jrbNacional)
                    .addComponent(jrbExtranjero)
                    .addComponent(jLabel20)
                    .addComponent(jcboPais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jpNacional, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel19)
                    .addComponent(jftReferencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbCancelar)
                    .addComponent(jbModificar)
                    .addComponent(jbEliminar)))
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jrbNacionalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbNacionalActionPerformed
        this.jcboPais.setSelectedIndex(0);
        this.jcboPais.setEnabled(false);
        this.ocultaPanel();
}//GEN-LAST:event_jrbNacionalActionPerformed

    private void jrbExtranjeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbExtranjeroActionPerformed
        ocultaPanel();
        this.jcboPais.setEnabled(true);
}//GEN-LAST:event_jrbExtranjeroActionPerformed

    private void jcboDistritoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcboDistritoItemStateChanged

}//GEN-LAST:event_jcboDistritoItemStateChanged

    private void jcboDepartamentoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcboDepartamentoItemStateChanged
      if (this.jcboDepartamento.getSelectedIndex() >= 0)
           this.llenarComboProvincia();
}//GEN-LAST:event_jcboDepartamentoItemStateChanged

    private void jcboDepartamentoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboDepartamentoKeyReleased

}//GEN-LAST:event_jcboDepartamentoKeyReleased

    private void jcboProvinciaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcboProvinciaItemStateChanged
       if (this.jcboProvincia.getSelectedIndex() >= 0)
           this.llenarComboDistrito();
}//GEN-LAST:event_jcboProvinciaItemStateChanged

    private void jbModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbModificarActionPerformed
        if (Utiles_MensajesDialogo.mensajeConfirmacion("Esta seguro de registrar el proveedor?")){
         try {
          verificaGuardaDatos();
          Utiles_MensajesDialogo.mensajeInfo("Se guardo el proveedor Correctamente");
          limpiar();
            this.llenarComboDepartamento();
            this.llenarComboPaises();
            this.llenarComboResidencia();
            this.llenarComboVia();
            Listas.cargarProveedores();
            Listas.cargarCosechador();
        }
        catch (Exception e) {
          Utiles_MensajesDialogo.mensajeError(e.getMessage());
        }
      }

}//GEN-LAST:event_jbModificarActionPerformed

    private void jbCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelarActionPerformed

        int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de salir?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
        if(res==javax.swing.JOptionPane.YES_OPTION){
            this.dispose();
        }
    }//GEN-LAST:event_jbCancelarActionPerformed

    private void jftfRazonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jftfRazonActionPerformed
        buscarRazonSocial();
    }//GEN-LAST:event_jftfRazonActionPerformed

    private void jbtBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtBuscarActionPerformed
        this.llenarComboDepartamento();
        this.llenarComboPaises();
        this.llenarComboResidencia();
        this.llenarComboVia();
        limpiar();
        buscarProveedor();
       
    }//GEN-LAST:event_jbtBuscarActionPerformed

    private void jftfRazonKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftfRazonKeyPressed
        if (this.jftRuc.getText().trim().length() > 0)
            this.jftRuc.setText("");
    }//GEN-LAST:event_jftfRazonKeyPressed

    private void jbEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbEliminarActionPerformed
        if (Utiles_MensajesDialogo.mensajeConfirmacion("Esta seguro de eliminar el proveedor?")){
         try {
         eliminarProveedor();
          Listas.cargarProveedores();
          Utiles_MensajesDialogo.mensajeInfo("Se elimino el proveedor Correctamente");
          limpiar();
            this.intelliHintsProveedor.setCompletionList(Listas.getProveedores());
        }
        catch (Exception e) {
          Utiles_MensajesDialogo.mensajeError(e.getMessage());
        }
      }

    }//GEN-LAST:event_jbEliminarActionPerformed

    private void jftRucActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jftRucActionPerformed
       if (this.jftRuc.getText().trim().length() < 1)
            this.jftRuc.requestFocus();
        else
            buscarRazonSocial();
    }//GEN-LAST:event_jftRucActionPerformed

    private void jftRucKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftRucKeyPressed

    }//GEN-LAST:event_jftRucKeyPressed

    private void jftDniKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftDniKeyPressed
         if(KeyEvent.VK_ENTER == evt.getKeyCode() ){
           try {
                Utiles_Validar.isValidoDNI(this.jftDni.getText());
                this.jftRepresentante.requestFocus();
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this,ex.getMessage(),"Erro de ingreso",JOptionPane.ERROR_MESSAGE );
            }
        }
    }//GEN-LAST:event_jftDniKeyPressed

    private void jftRepresentanteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftRepresentanteKeyPressed
         if(KeyEvent.VK_ENTER == evt.getKeyCode() ){
           this.jftTelefono.requestFocus();
        }
    }//GEN-LAST:event_jftRepresentanteKeyPressed

    private void jftTelefonoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftTelefonoKeyPressed
       if(KeyEvent.VK_ENTER == evt.getKeyCode() ){
           this.jftFax.requestFocus();
        }
    }//GEN-LAST:event_jftTelefonoKeyPressed

    private void jftFaxKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftFaxKeyPressed
        if(KeyEvent.VK_ENTER == evt.getKeyCode() ){
           this.jftCorreo.requestFocus();
        }
    }//GEN-LAST:event_jftFaxKeyPressed

    private void jftCorreoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftCorreoKeyPressed
       if(KeyEvent.VK_ENTER == evt.getKeyCode() ){
           this.jftGiroNegocio.requestFocus();
        }
    }//GEN-LAST:event_jftCorreoKeyPressed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private administracion.BeanBinding.CboBeanBindingDepartamento cboBeanBindingDepartamento1;
    private administracion.BeanBinding.CboBeanBindingDistrito cboBeanBindingDistrito1;
    private administracion.BeanBinding.CboBeanBindingPais cboBeanBindingPais1;
    private administracion.BeanBinding.CboBeanBindingProvincia cboBeanBindingProvincia1;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo1;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JButton jbCancelar;
    private javax.swing.JButton jbEliminar;
    private javax.swing.JButton jbModificar;
    private javax.swing.JButton jbtBuscar;
    private javax.swing.JComboBox jcboDepartamento;
    private javax.swing.JComboBox jcboDistrito;
    private javax.swing.JComboBox jcboLugarResidencia;
    private javax.swing.JComboBox jcboPais;
    private javax.swing.JComboBox jcboProvincia;
    private javax.swing.JComboBox jcboTipoVia;
    private javax.swing.JCheckBox jckCosechador;
    private javax.swing.JTextField jftCorreo;
    private javax.swing.JFormattedTextField jftDni;
    private javax.swing.JTextField jftFax;
    private javax.swing.JTextField jftGiroNegocio;
    private javax.swing.JTextField jftNumero;
    private javax.swing.JTextField jftReferencia;
    private javax.swing.JTextField jftRepresentante;
    private javax.swing.JTextField jftResidencia;
    private javax.swing.JFormattedTextField jftRuc;
    private javax.swing.JTextField jftTelefono;
    private javax.swing.JTextField jftVia;
    private javax.swing.JTextField jftfRazon;
    private javax.swing.JPanel jpNacional;
    private javax.swing.JRadioButton jrbExtranjero;
    private javax.swing.JRadioButton jrbNacional;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

}
